//Εγγραφη στο συστημα για πιθανη καταχωρηση καταστηματος.
package Controllers;

import DAO.SignUp_Dao;
import Exceptions.DaoException;

public class SignUp_Controller {

    public SignUp_Controller() {

    }
    public SignUp_Controller(SignUp_Dao signUp_Dao) {
    }

    public boolean validateSignUp(String Name, String LastName, String Phone, String Email, String Username, String Password, String Repass)
            throws IllegalArgumentException, DaoException {
        boolean x = false;
        try {
            if (Name.isEmpty() || LastName.isEmpty() || Phone.isEmpty() || Email.isEmpty() || Username.isEmpty() || Password.isEmpty() || Repass.isEmpty()) {
                x = false;
            } else if (!Email.contains("@") || !Email.contains(".") || Email.startsWith("@")) {
                x = false;
            } else if (!Phone.matches("[0-9]+")) {
                x = false;
            } else if (Phone.length() > 10 || Phone.length() < 10) {
                x = false;
            } else if (!Password.equals(Repass)) {
                x = false;
            } else {
                DAO.SignUp_Dao y = new DAO.SignUp_Dao();
                y.makeRegister(Name, LastName, Phone, Email, Username, Password, Repass);
                x= true;
            }
        } catch (IllegalArgumentException e) {
                throw new IllegalArgumentException("Error in SignUp_Controller");
        }
        
        return x;
    }
}
